Expand description
A library for parsing CSL styles.
Citationberg deserializes CSL styles from XML into Rust structs. It supports CSL 1.0.2.
This crate is not a CSL processor, so you are free to choose whatever data model and data types you need for your bibliographic needs. If you need to render citations, you can use Hayagriva which uses this crate under the hood.
Parse your style like this:
use std::fs;
use citationberg::Style;
let string = fs::read_to_string("tests/independent/ieee.csl")?;
let style = citationberg::Style::from_xml(&string)?;
let Style::Independent(independent) = style else {
panic!("IEEE is an independent style");
};
assert_eq!(independent.info.title.value, "IEEE");
You can also parse a DependentStyle
or a IndependentStyle
directly.
Modules§
- CSL constants that describe entries, terms, and variables.
Structs§
- Prefixes and suffixes.
- Formatting instructions for the bibliography.
- A conditional group of formatting instructions.
- A single branch of a conditional group.
- Formatting instructions for in-text or note citations.
- A reusable set of formatting instructions.
- Formats a date.
- Override the default date parts.
- A dependent CSL style.
- The formatting instructions to use if no branch matches.
- Configure the et al. abbreviation.
- Formatting properties.
- A group of formatting instructions that is only shown if no variable is referenced or at least one referenced variable is populated.
- An independent CSL style.
- A style with its own formatting rules.
- A link with more information about the style.
- Global configuration of how to print names.
- Print a label for a number variable.
- A formatting rule.
- A license description.
- A string annotated with a locale.
- Supplemental localization data in a citation style.
- An RFC 1766 language code.
- Root element of a locale file.
- Metadata of a locale.
- Options for the locale.
- A localized term.
- Configuration of how to print names.
- Definite name options. Obtain from
Name::options
usingInheritableNameOptions
. - How to format a given name part.
- Renders a list of names.
- Renders a number.
- Get the right forms of ordinal terms for numbers.
- How to sort elements in a bibliography or citation.
- A person affiliated with the style.
- Citation style metadata
- What to do if the name variable is empty.
- Term localization container.
- Print a term or variable.
- An ISO 8601 chapter 5.4 timestamp.
- A label without its variable.
Enums§
- The base language in a
LocaleCode
. - How to handle the set of tests in a conditional group.
- A single test in a conditional group.
- What type of in-text citation is used.
- How to collapse cites with similar items.
- Any allowable date part format.
- How a day is formatted.
- Localized date formats.
- How a month is formatted.
- The kind of a date part with its
form
attribute. - Which parts of a date should be included.
- Strongly typed date part formats.
- When delimiters shall be inserted.
- How to treat the non-dropping name particle when printing names.
- When to expand names that are ambiguous in short form.
- On which layout level to display the citation.
- Which term to use for et al.
- In which academic field the style is used.
- Font style.
- Font variant.
- Font weight.
- A grammatical gender. Use
None
for neutral. - How a link relates to the style.
- How to pluralize a label.
- Possible parts of a formatting rule.
- Whether to format something in long or short form.
- How to render the delimiter before the last name.
- In which order to print the names.
- How many name parts to print.
- Where the
cs:label
element within acs:names
element appeared relative tocs:name
. - Which part of the name a
NamePart
applies to. - Possible children for a
cs:names
element. - How a number is formatted.
- Specify when which ordinal term is used.
- How to reformat page ranges.
- How much metadata to remove from the style.
- Rendering elements.
- How to position the first field if the second field is aligned in a bibliography.
- The direction to sort in.
- A sorting key.
- A CSL style.
- Which category this style belongs in.
- How the citations are displayed.
- An error that occurred while validating a style.
- How to replace subsequent identical names in a bibliography.
- The variant of a term translation.
- Possible positions of a citation in the citations to the same item.
- How to format text.
- Text decoration.
- Various kinds of text targets.
- Vertical alignment.
Traits§
- Allow every struct with affix properties to convert to a
Affixes
. - Allow every struct with formatting properties to convert to a
Formatting
.
Type Aliases§
- Error type for functions that serialize and deserialize XML.
- Result type for functions that serialize and deserialize XML.